package org.study.neo4j.boot.repository;

import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.data.repository.query.Param;
import org.study.neo4j.boot.model.Teacher;

import java.util.List;

/**
 * 作用描述
 *
 * @author doveylovey
 * @version v1.0.0
 * @email 1135782208@qq.com
 * @date 2025年04月09日
 */
public interface TeacherRepository extends Neo4jRepository<Teacher, Long> {
    List<Teacher> findByName(String name);

    @Query("MATCH (t:Teacher)-[:TEACHES]->(c:Course) WHERE c.code = $courseCode RETURN t")
    Teacher findByCourseCode(@Param("courseCode") String courseCode);

    @Query("MATCH (t:Teacher)-[:ADVISES]->(s:Student) WHERE s.name = $studentName RETURN t")
    List<Teacher> findAdvisorsByStudentName(@Param("studentName") String studentName);
}
